import 'package:flutter/material.dart';

class Header extends StatelessWidget {
  Widget _unLoginWidget(BuildContext context) {
    return Container(
      decoration: BoxDecoration(color: Colors.green),
      height: 80,
      child: Row(
        children: [
          Container(
            margin: EdgeInsets.only(left: 20),
            child: CircleAvatar(
              backgroundImage: AssetImage('images/unlogin.png'),
            ),
            width: 50,
            height: 50,
          ),
          Padding(padding: EdgeInsets.only(left: 10)),
          GestureDetector(
            onTap: () {
              Navigator.pushNamed(context, 'login');
            },
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Text(
                  '登录/注册',
                  style: TextStyle(
                      color: Colors.white,
                      fontSize: 15,
                      fontWeight: FontWeight.w500),
                ),
                Padding(padding: EdgeInsets.only(top: 3)),
                Text('登录后可以体验更多',
                    style: TextStyle(color: Colors.white, fontSize: 10))
              ],
            ),
          )
        ],
      ),
    );
  }

  Widget _loginWidget(BuildContext context) {
    return Container(
      decoration: BoxDecoration(color: Colors.green),
      height: 80,
      child: Row(
        children: [
          Container(
            margin: EdgeInsets.only(left: 20),
            child: CircleAvatar(
              backgroundImage: AssetImage('images/login.png'),
            ),
            width: 50,
            height: 50,
          ),
          Padding(padding: EdgeInsets.only(left: 10)),
          GestureDetector(
            onTap: () {},
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Text(
                  '已登录',
                  style: TextStyle(
                      color: Colors.white,
                      fontSize: 15,
                      fontWeight: FontWeight.w500),
                ),
                Padding(padding: EdgeInsets.only(top: 3)),
                Text('编辑个人资料',
                    style: TextStyle(color: Colors.white, fontSize: 10))
              ],
            ),
          )
        ],
      ),
    );
  }

  bool _is_login = false;
  @override
  Widget build(BuildContext context) {
    return _is_login ? _loginWidget(context) : _unLoginWidget(context);
  }
}
